parent = property(dirname, None, None, " This path's parent directory, as a new path object.\n\n For example, path('/usr/local/lib/libpython.so').parent == path('/usr/local/lib')\n ")
name = property(basename, None, None, " The name of this file or directory without the full path.\n\n For example, path('/usr/local/lib/libpython.so').name == 'libpython.so'\n ")
namebase = property(_get_namebase, None, None, " The same as path.name, but with one file extension stripped off.\n\n For example, path('/home/guido/python.tar.gz').name == 'python.tar.gz',\n but path('/home/guido/python.tar.gz').namebase == 'python.tar'\n ")
ext = property(_get_ext, None, None, " The file extension, for example '.py'. ")
drive = property(_get_drive, None, None, " The drive specifier, for example 'C:'.\n This is always empty on systems that don't use drive specifiers.\n ")
def splitpath(self):
(parent, child) = os.path.split(self)
return (self.__class__(parent), child)
def splitdrive(self):
(drive, rel) = os.path.splitdrive(self)
return (self.__class__(drive), rel)
def splitext(self):
(filename, ext) = os.path.splitext(self)
return (self.__class__(filename), ext)
def stripext(self):
return self.splitext()[0]
if hasattr(os.path, 'splitunc'):
def splitunc(self):
(unc, rest) = os.path.splitunc(self)
return (self.__class__(unc), rest)
def _get_uncshare(self):
(unc, r) = os.path.splitunc(self)
return self.__class__(unc)
uncshare = property(_get_uncshare, None, None, ' The UNC mount point for this path.\n This is empty for paths on local drives. ')
def joinpath(self, *args):
return self.__class__(pathjoin(self, *args))
def splitall(self):
parts = []
loc = self
while loc != os.curdir and loc != os.pardir:
prev = loc
(loc, child) = prev.splitpath()
if loc == prev:
break
parts.append(child)
parts.append(loc)
parts.reverse()
return parts
def relpath(self):
cwd = self.__class__(os.getcwd())
return cwd.relpathto(self)
def relpathto(self, dest):
origin = self.abspath()
dest = self.__class__(dest).abspath()
orig_list = origin.normcase().splitall()
dest_list = dest.splitall()
if orig_list[0] != os.path.normcase(dest_list[0]):
return dest
i = 0
for start_seg, dest_seg in zip(orig_list, dest_list):